package com.share.user.service;

import com.share.user.dao.SyUserDao;
import com.share.user.model.SyUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Objects;

/**
 * @author 小赵
 * @version 1.0
 * @date 2024-10-11 16:41
 */

@Service
@Slf4j
public class SyUserServiceImp implements SyUserService {

    @Autowired
    private SyUserDao syUserDao;



    @Override
    public Boolean login(String username, String password) {
        try {
            SyUser login = syUserDao.login(username, password);
            return login != null;
        } catch (Exception e) {
            log.error("登录操作失败: {}", e.getMessage(), e);
            throw e;
        }
    }


    @Override
    public boolean checkIsExistsUsername(String username) {
        Integer count = syUserDao.checkIsExistsUsername(username);
        return Objects.nonNull(count) && count > 0;
    }

    @Override
    public SyUser getUserIdByUsername(String username){
        return syUserDao.getUserIdByUsername(username);
    }



}
